/********************************************************************************* * Seg 2501, hiver 2002 Devoir # 4 * * fichier Banque.java * simulator controller and statistics reporting * * @author Anne Bertrand * @author Robin Tropper * @refactoredBy Robin Tropper B.A.Sc. * * BUG : it sometimes happened (past) that cashiers could not see that "the bank * is closed" => result: infinite loop when a cashier is looking for the next client. * => SHOULD BE fixed, but difficult to formally prove. * **********************************************************************************/ import java.util.*; public class Bank { private static int numCashiers = 3; private static long duration = 3600; private static boolean quittingTime = false; static Timer finished = new Timer(); //time limit for entire simulation static ClientQueue enterpriseQueue = new ClientQueue(300,100,duration, " Entreprise"); static ClientQueue individualsQueue = new ClientQueue(50,50,duration," Individual"); /** * By default, there is only one queue for enterprises and one queue for individuals. * The following method aims to favor scalability where multiple queues and multiple * priorities are allowed; i.e. an unknown number of queues where the priorities must * still be respected. * * @return : the liste of queues in descending order of priority. * In other words, looping throught the list respects the priorities. */ public static synchronized List showQueues(){ List queueList = new ArrayList(); queueList.add(0, enterpriseQueue); queueList.add(1, individualsQueue); return queueList; }//fin montreFiles public static boolean isClosed(){ return quittingTime; }//fin getCloture //##### // main //##### public static void main(String[] args) { System.out.println("Simulation for "+numCashiers+" cashiers over "+ duration/600+" hours."); System.out.println("Please wait "+duration/600+ " seconds for the results"); finished.schedule(new Terminer(), duration); System.out.println("NUMBER OF CASHIERS "+numCashiers); for (int k=0; k